package com.organization.model.dao.impl

import org.springframework.stereotype.Repository
import com.organization.util.CustomHibernateDaoSupport
import com.organization.model.dao.DepartmentDao
import com.organization.model.Department
import javax.validation.Validator
import javax.validation.ValidatorFactory
import javax.validation.Validation
import javax.validation.ConstraintViolation

/**
 * Created with IntelliJ IDEA.
 * User: inester
 * Date: 09.07.12
 * Time: 12:15
 * To change this template use File | Settings | File Templates.
 */
@Repository("departmentDao")
public class DepartmentDaoImpl extends CustomHibernateDaoSupport implements DepartmentDao{

    @Override
    public void save(Department dep){

        getHibernateTemplate().save(dep);
    }

    @Override
    public void update(Department dep){
        getHibernateTemplate().update(dep);
    }

    @Override
    public void delete(Department dep){
        getHibernateTemplate().delete(dep);
    }

    @Override
    List<Department> departmentList() {
        getHibernateTemplate().find("from Department")
    }

    @Override
    Department get(int id) {
        List<Department> deps = getHibernateTemplate().findByNamedParam("from Department where id = :depId","depId",id)
        return deps[0]
    }
}
